<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript" src="js/lib/jquery.min.js"></script>
    <link rel="stylesheet" href="fonts/iconfont.css">
    <link href="css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="css/bootstrap.css"/>
    <link rel="stylesheet/less" type="text/css" href="css/xStyle.less"/>
    <script type="text/javascript" src="js/lib/less.js"></script>
    <style>
      
    </style>
</head>

<body>
<div>

    <div>
        <div>
            <div id='div1'></div>
        </div>

    </div>


</div>
</body>
<script type="module">
    import xCRUD from './js/src/xCRUD.js';
    import {queryCols, tableCols, viewCols,updateBinds} from './js/data/CRUD.js'
    import {getModuleHis, getApiHistory,delLogSingle,
    	batchDeleteLog,insertlog,updatelog} from './js/src/api.js';

    let modalList = [];


    getModuleHis(function (res) {
        if (res.code == '200')
            queryCols[1].cfg.data.push(...res.data);
    });


    function cbQueryParam(param) {
       
        let newParam = {...param};
        newParam.beginDate = param.logDate.split(',')[0];
        newParam.endDate = param.logDate.split(',')[1];
        if(param.modType)
            newParam.modType = param.modType.split(',');
        if (param.module)
            newParam.module = param.module.code;
        return newParam;
    };

    function cbReset(obj) {
        obj.logDate = '2022-03-01,2022-03-02';
        obj.module = '';
        obj.modType = '';
    }


    let cfg = {
        el: 'div1',
        cb: {queryParam: cbQueryParam, resetParma: cbReset,
        	 retrieve: getApiHistory,delete:delLogSingle,
        	 batchDelete:batchDeleteLog,
        	 insert:insertlog,update:updatelog},
        query:{
            cols: queryCols,
            obj: {logDate: '2022-02-20,2022-03-02', modType: null, module: null}
        },
        table: {
            cols: tableCols,
            data: [],
            pagination: {
                pageIndex: 1,
                pageSize: 20,
                sizeOption: ["20", "50", "100", "200"]
            }
        },
        view: {
            cols: viewCols,
            style: 'modal-lg',
            col: 'col-md-4',
            tag:true
        },
        update:{
        	style:'modal-xl',
        	binds:updateBinds,
        	obj:{
        		logDate:'2022-03-10 08:00:00',
        		modType:'insert',
        		apiId: 10001,
        		module:'test'
        	},
        	col: 'col-md-6',
        	tag:true
        },
        right: {create: true, batchDelete: true, update: true, delete: true}
    }

    let crud = new xCRUD(cfg);


</script>

</html>